home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Dev / Oberon / examples.lha / Examples / Oberon0 / Oberon0.Mod < prev    next >
Encoding:
Text File  |  1995-04-15  |  965 b   |  34 lines

  1. MODULE Oberon0;  (* HM Mar-25-92*)
  2. IMPORT OS, Viewers0, Texts0, TextFrames0;
  3.  
  4. CONST ESC = 1BX;
  5.  
  6. PROCEDURE Open (name: ARRAY OF CHAR): Texts0.Text;
  7.   VAR f: OS.File; r: OS.Rider; t: Texts0.Text;
  8. BEGIN NEW(t); f := OS.OldFile(name);
  9.   IF f = NIL THEN t.Clear ELSE OS.InitRider(r); r.Set(f, 0); t.Load(r) END;
  10.   RETURN t
  11. END Open;
  12.  
  13. PROCEDURE Loop*;
  14.   VAR ch: CHAR; x, y: INTEGER; buttons: SET; v: Viewers0.Viewer; menu, cont: TextFrames0.Frame;
  15. BEGIN
  16.   menu := TextFrames0.NewMenu("LOG", "Viewers0.Close  Viewers0.Copy  Edit0.Store");
  17.   cont := TextFrames0.New(Open("LOG"));
  18.   v := Viewers0.New(menu, cont);
  19.   LOOP
  20.     IF OS.AvailChars() > 0 THEN OS.ReadKey(ch);
  21.       IF ch = ESC THEN EXIT
  22.       ELSIF Viewers0.focus # NIL THEN Viewers0.focus.HandleKey(ch)
  23.       END
  24.     ELSE OS.GetMouse(buttons, x, y);
  25.       v := Viewers0.ViewerAt(y);
  26.       IF v # NIL THEN v.HandleMouse(x, y, buttons)
  27.       ELSE OS.DrawCursor(x, y)
  28.       END
  29.     END
  30.   END
  31. END Loop;
  32.  
  33. END Oberon0.
  34.